package com.zf.apartment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zf.common.annotation.Log;
import com.zf.common.core.controller.BaseController;
import com.zf.common.core.domain.AjaxResult;
import com.zf.common.enums.BusinessType;
import com.zf.apartment.domain.PropertyRoomdata;
import com.zf.apartment.service.IPropertyRoomdataService;
import com.zf.common.utils.poi.ExcelUtil;
import com.zf.common.core.page.TableDataInfo;

/**
 * 房间属性Controller
 * 
 * @author rxf
 * @date 2024-10-09
 */
@RestController
@RequestMapping("/apartment/roomdata")
public class PropertyRoomdataController extends BaseController
{
    @Autowired
    private IPropertyRoomdataService propertyRoomdataService;

    /**
     * 查询房间属性列表
     */
    @PreAuthorize("@ss.hasPermi('apartment:roomdata:list')")
    @GetMapping("/list")
    public TableDataInfo list(PropertyRoomdata propertyRoomdata)
    {
        startPage();
        List<PropertyRoomdata> list = propertyRoomdataService.selectPropertyRoomdataList(propertyRoomdata);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('apartment:roomdata:list')")
    @GetMapping("/find")
    public TableDataInfo find(PropertyRoomdata propertyRoomdata)
    {
        startPage();
        List<PropertyRoomdata> list = propertyRoomdataService.findPropertyRoomdataList(propertyRoomdata);
        return getDataTable(list);
    }

    /**
     * 导出房间属性列表
     */
    @PreAuthorize("@ss.hasPermi('apartment:roomdata:export')")
    @Log(title = "房间属性", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyRoomdata propertyRoomdata)
    {
        List<PropertyRoomdata> list = propertyRoomdataService.selectPropertyRoomdataList(propertyRoomdata);
        ExcelUtil<PropertyRoomdata> util = new ExcelUtil<PropertyRoomdata>(PropertyRoomdata.class);
        util.exportExcel(response, list, "房间属性数据");
    }

    /**
     * 获取房间属性详细信息
     */
    @PreAuthorize("@ss.hasPermi('apartment:roomdata:query')")
    @GetMapping(value = "/{propertyRoomDataId}")
    public AjaxResult getInfo(@PathVariable("propertyRoomDataId") Long propertyRoomDataId)
    {
        return success(propertyRoomdataService.selectPropertyRoomdataByPropertyRoomDataId(propertyRoomDataId));
    }

    /**
     * 新增房间属性
     */
    @PreAuthorize("@ss.hasPermi('apartment:roomdata:add')")
    @Log(title = "房间属性", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyRoomdata propertyRoomdata)
    {
        return toAjax(propertyRoomdataService.insertPropertyRoomdata(propertyRoomdata));
    }

    /**
     * 修改房间属性
     */
    @PreAuthorize("@ss.hasPermi('apartment:roomdata:edit')")
    @Log(title = "房间属性", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyRoomdata propertyRoomdata)
    {
        return toAjax(propertyRoomdataService.updatePropertyRoomdata(propertyRoomdata));
    }

    /**
     * 删除房间属性
     */
    @PreAuthorize("@ss.hasPermi('apartment:roomdata:remove')")
    @Log(title = "房间属性", businessType = BusinessType.DELETE)
	@DeleteMapping("/{propertyRoomDataIds}")
    public AjaxResult remove(@PathVariable Long[] propertyRoomDataIds)
    {
        return toAjax(propertyRoomdataService.deletePropertyRoomdataByPropertyRoomDataIds(propertyRoomDataIds));
    }
}
